package com.wc.alorithm_luogu.P1059;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/5/7 20:51
 * @description
 * https://www.luogu.com.cn/problem/P1059
 *  明明的随机数
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];

        while (n-- > 0) {
            array[n] = sc.nextInt();
        }

        // 排序
        Arrays.sort(array);

        int index = 0;

        // 原地去重
        for (int i = 1; i < array.length; i++) {
            if (array[i - 1] != array[i]) {
                array[index] = array[i - 1];
                index++;
            }
        }
        if (array[array.length - 1] != array[array.length - 2]) {
            array[index] = array[array.length - 1];
            index++;
        }
        System.out.println(index);
        System.out.print(array[0]);
        for (int i = 1; i < index; i++) {
            System.out.print(" " + array[i]);
        }
    }
}
